<!--style-->
<style>
#block-first .banner .more {
    overflow: visible;
    margin: 0 8px 0 0;
    padding: 0;
}

#block-first .banner .more:hover {
    background: none;
    box-shadow: none;
}

#block-first .mainer {
    padding: 8px;
}

#block-first .unit .l {
    width: 120px;
    padding: 0 0 0 40px;
}

#block-first .unit .r {
    width: 620px;
}

#block-first .subtitle {
    margin: 4px 0;
    height: 24px;
    line-height: 24px;
    font-size: 13px;
    padding: 0 4px;
    border-radius: 2px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    background-color: #c66;
    color: #fff;
    display: inline-block;
    *display: inline;
    cursor: default;
}

#block-first .item {
    position: relative;
    overflow: hidden;
    border-color: rgba(0, 0, 0, 0.1);
}

.no-rgba #block-first .item {
    border-color: #ccc;
}

#block-first .inner {
    position: relative;
}

#block-first .item .l {
    position: relative;
}

#block-first .item .r {
    position: relative;
    width: 540px;
}

#block-first .item .thumb {
    border: none;
    background: none;
    box-shadow: none;
}

#block-first .item .preview {
    width: 120px;
    height: 90px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    background-color: #fff;
    border-radius: 2px;
}

#block-first .item .avatar {
    width: 40px;
    height: 40px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    background-color: #fff;
    border-radius: 2px;
}

#block-first .item .thumb-preview {
    margin: 8px 0 16px 8px;
}

#block-first .item .thumb-avatar {
    position: absolute;
    left: 96px;
    top: 64px;
}

#block-first .item .block-title {
    margin: 10px auto 0;
}

#block-first .item .channel {
    background-color: #c66;
    position: static;
    display: inline-block;
    *display: inline;
    margin: 0 4px 4px 0;
    padding: 0 4px;
}

#block-first .item .title {
    color: #08c;
    font-size: 14px;
}

#block-first #list-push-push .item .info {
    color: #999;
    margin: 4px auto 0;
}

#block-first .item .desc {
    color: #666;
    margin: 4px auto 0;
}

#block-first .item .block-manage {
    position: absolute;
    left: auto;
    top: auto;
    right: -128px;
    bottom: 8px;
    transition: 0.2s all ease 0.2s;
}

#block-first .item:hover .block-manage {
    right: 8px;
}

#block-first .area-tag {
    display: inline-block;
    *display: inline;
    border-top: 1px dashed #ddd;
    margin: 8px 0 16px;
    padding: 8px 16px 0 0;
    color: #999;
    font-size: 12px;
}

#block-first .area-tag a {
    margin: 0 8px 8px 0;
    color: #369;
}

#block-first .btn-history-delete {
    float: right;
    height: 24px;
    line-height: 24px;
    font-size: 12px;
    color: #999;
    background-color: #eee;
    padding: 0 8px;
    border-radius: 2px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-family: "Microsoft YaHei", "微软雅黑", tahoma, arial, simsun, "宋体";
    margin: 4px;
}

#block-first .btn-history-delete:hover {
    color: #fff;
    background-color: #c33;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

#block-first .removed {
    text-align: center;
    line-height: 8;
    color: #999;
}

#block-first .hint-list-index {
    position: absolute;
    left: auto;
    top: auto;
    right: 12px;
    bottom: 0px;
    font-size: 64px;
    line-height: 64px;
    height: 64px;
    width: auto;
    text-align: right;
    color: #eee;
    z-index: 0;
    letter-spacing: -0.1em;
    cursor: default;
}

#block-first .area-pager {
    padding: 0;
    margin: 8px auto;
}

#block-first .item .area-cont {
    width: auto;
    height: auto;
    margin: 8px 10px;
    padding: 8px;
    background-color: #ffe;
    color: #333;
    display: none;
    border: 1px solid #dddddd;
    border-top: 1px solid #ebebeb;
    border-bottom: 1px solid #b7b7b7;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

#block-first .item-comms .area-cont {
    display: block;
}

#list-channel-push {
    margin: 8px auto 16px;
    padding: 0 0 16px;
    border-bottom: 1px dashed #ddd;
}

#list-group-push {
    overflow: visible;
    margin: 0 auto 16px;
    padding: 0 0 16px;
    border-bottom: 1px #ddd dashed;
}

#list-group-push .item {
    display: inline-block;
    *display: inline;
    float: left;
    margin: 4px 8px 0 0;
}

.btn-manage-push {
    min-width: 0px;
    *width: auto;
    padding: 0;
}

.btn-manage-push .icon {
    margin: 0 4px;
}

#list-push-push .item {
    background-color: #fff;
}
</style>
<!--style-->

<!--html-->
<div id="block-title-banner">
    <p>推送</p>

    <div>
        <a href="user">PowerOJ</a>
        <span class="d">Push</span>
    </div>
    <span class="clearfix"></span>
</div>
<div id="block-banner-right" class="block banner">
    <i class="location"></i>
</div>
<div id="temp-group-push" class="hidden">
    <div class="item" data-gid="[gid]" data-count="[count]" data-name="[name]">
        <div class="btn mini btn-group-push">
            [name]
        </div>
        <span class="clearfix"></span>
    </div>
</div>
<div id="temp-item-push" class="hidden">
    <div class="item block" data-aid="[aid]">
        <div class="inner">
            <p class="hint-list-index">[index]</p>

            <div class="l">
                <a target="_blank" href="/v/ac[aid]" class="thumb thumb-preview">
                    <img data-aid="[aid]" [preview] class="preview">
                    <div class="cover"></div>
                </a>
                <a target="_blank" href="user/profile/[name]" class="thumb thumb-avatar"
                   title="点击访问[[name]]的个人空间">
                    <img data-uid="[uid]" [avatar] class="avatar">
                </a>
            </div>
            <div class="r">
                <p class="block-title">
                    <a href="/v/list[cid]/index.htm" class="channel" title="点击访问[channel]频道"
                       target="_blank">[channel]</a>
                    <a data-aid="[aid]" target="_blank" href="/v/ac[aid]" class="title">[title]</a>
                </p>

                <div class="info">
                    <a target="_blank" href="user/profile/[name]" class="name">[name]</a>
                    &nbsp;&nbsp;/&nbsp;&nbsp;发布于
                    <span class="time">[date]</span>
                    &nbsp;&nbsp;/&nbsp;&nbsp;播放:
                    <span class="views pts">[views]</span>
                    &nbsp;&nbsp;评论:
                    <span class="comments pts">[comments]</span>
                    &nbsp;&nbsp;收藏:
                    <span class="favors pts">[favors]</span>
                </div>
                <p class="desc">[desc]</p>

                <div class="area-tag">[tags]</div>
            </div>
            <span class="clearfix"></span>
        </div>
    </div>
</div>
<div id="block-first" class="block">
    <div class="mainer">

        <p class="alert alert-info">
            我们为关注列表增加了分组功能，以使您可以更快捷的获得需要的推送内容。<br/>
            您可以在<a href="#area=following">[这里]</a>操作您的关注列表分组。
        </p>

        <div class="unit">
            <div id="list-group-push">
                <div class="item">
                    <div id="btn-all-push" class="btn mini primary">
                        <i class="icon white icon-list"></i>展示全部
                    </div>
                    <span class="clearfix"></span>
                </div>
                <span class="clearfix"></span>
            </div>
        </div>

        <div id="list-push-push"></div>

    </div>
</div>
<!--html-->

<!--script-->
<script>
system.tv = function () {
    //set handle
    var block = $('#block-first');
    var mainer = block.find('div.mainer').eq(0);
    var list = $('#list-push-push');
    //function
    var showGroup = function () {
        //set handle
        var temp = $('#temp-group-push').html();
        if (system.port.getGroup) {
            system.port.getGroup.abort();
        }
        ;
        system.port.getGroup = $.get('api/friend/getGroupList')
                .done(function (data) {
                    var html = '';
                    if (data.success) {
                        //
                        for (var i = 0, l = data.groupList.length; i < l; i++) {
                            var a = data.groupList[i];
                            if (a.id && a.id > 0) {
                                html += temp
                                        .replace(/\[gid\]/g, a.id)
                                        .replace(/\[count\]/g, a.count || 0)
                                        .replace(/\[name\]/g, $.parseSafe(a.name || "非法分组"))
                                ;
                            }
                            ;
                        }
                        ;
                        $('#btn-all-push').parent()
                                .after(html);
                        /*$('#list-group-push')
                         //dropdown
                         .find('div.dropdown')
                         .setup();
                         */
                        //
                        $('#btn-all-push').click();
                    } else {
                        $.info('error::' + data.result);
                        var html = '<p class="alert alert-error">' + data.result + '</p>';
                        $('#list-push-push')
                                .html(html);
                    }
                    ;
                })
                .fail(function () {
                    $.info('error::获取关注分组失败。请于稍后重试。');
                    var html = '<p class="alert alert-error">获取关注分组失败。请于稍后重试。</p>';
                    $('#list-push-push')
                            .html(html);
                });
    };
    var showList = function (param) {
        //inner func
        var func = {
            size: param.size || 10,
            page: param.page || 1,
            gid: param.gid || 0,
            isGroup: param.isGroup || 0
        };
        //port
        if (system.port.getpushList) {
            system.port.getpushList.abort();
        }
        ;
        system.port.getpushList = $.get('api/user/publishContent', {
            isGroup: func.isGroup,
            groupId: func.gid,
            pageSize: func.size,
            pageNo: func.page
        })
                .done(function (data) {
                    if (data.success) {
                        //
                        if (data.contents.length) {
                            //
                            var temp = $('#temp-item-push').html();
                            var html = '';
                            for (var i = 0, l = data.contents.length; i < l; i++) {
                                var a = data.contents[i];
                                //set tags
                                var tag = '该视频暂无标签。';
                                if (a.tags && a.tags.length) {
                                    tag = '';
                                    var tags = a.tags.replace(/\s/g, '').split(',');
                                    for (var j = 0, m = tags.length; j < m; j++) {
                                        tag += '<a class="tag" href="search#query=' + encodeURI(tags[j]) + '" target="_blank">' + tags[j] + '</a>';
                                    }
                                    ;
                                }
                                ;
                                html += temp
                                        .replace(/\[aid\]/g, a.aid)
                                        .replace(/\[cid\]/g, a.channelId)
                                        .replace(/\[preview\]/g, 'src="' + a.titleImg + '"')
                                        .replace(/\[uid\]/g, a.userId)
                                        .replace(/\[avatar\]/g, 'src="' + a.avatar + '"')
                                        .replace(/\[channel\]/g, $.parseChannel(a.channelId))
                                        .replace(/\[title\]/g, a.title)
                                        .replace(/\[name\]/g, a.username)
                                        .replace(/\[date\]/g, $.parseTime(a.releaseDate))
                                        .replace(/\[views\]/g, a.views)
                                        .replace(/\[comments\]/g, a.comments)
                                        .replace(/\[favors\]/g, a.stows)
                                        .replace(/\[desc\]/g, $.parseSafe(a.description || '此视频暂无简介。'))
                                        .replace(/\[tags\]/g, tag)
                                        .replace(/\[index\]/g, data.page.totalCount - (data.page.pageNo - 1) * data.page.pageSize - i)
                                ;
                                //pager
                                var pager = $.makePager({
                                    num: data.page.pageNo,
                                    count: data.page.totalCount,
                                    size: data.page.pageSize,
                                    addon: true
                                });
                                //insert dom
                                list
                                        .data({
                                            gid: func.gid
                                        })
                                        .html(pager + html + pager)
                                        .find('a.name')
                                        .card();
                                //scroll
                                $('#stage').scrollOnto(0);
                            }
                            ;
                        } else {
                            $.info('尚未有任何推送项目。');
                            html = '<p class="alert">尚未有任何推送项目。</p>';
                            list.html(html);
                        }
                        ;
                    } else {
                        $.info('error::' + data.result);
                    }
                    ;
                })
                .fail(function () {
                    $.info('error::获取推送列表失败。请于稍后重试。');
                });
    };
    //bind action
    $('#btn-all-push')
            .click(function () {
                $('#list-group-push').find('div.btn-group-push.active').removeClass('active primary');
                $(this)
                        .addClass('active primary')
                    //icon
                        .children('i.icon')
                        .addClass('white')
                ;
                showList({
                    gid: -1,
                    isGroup: 0,
                    page: 1,
                    size: 10
                });
            });
    $('#list-group-push')
        //change group
            .delegate('div.btn-group-push', 'click', function () {
                var btn = $(this);
                var obj = btn.parent();
                var list = obj.parent();
                if (!btn.hasClass('active')) {
                    list.find('div.btn-group-push.active')
                            .add('#btn-all-push')
                            .removeClass('active primary')
                        //icon
                            .children('i.icon')
                            .removeClass('white')
                    ;
                    btn
                            .addClass('active primary')
                    ;
                    showList({
                        gid: obj.data().gid,
                        isGroup: 1,
                        page: 1,
                        size: 10
                    });
                }
                ;
            })
    ;
    $('#list-push-push')
        //pager
            .readyPager({
                addon: true,
                callback: function (n) {
                    //
                    showList({
                        isGroup: ($('#list-push-push').data().gid != -1 ? 1 : 0),
                        gid: $('#list-push-push').data().gid,
                        page: n,
                        size: 10
                    });
                }
            })
    ;
    //
    showGroup();
    //
    $('#hint-newPush-guide').addClass('hidden');
}();
</script>
<!--script-->